package cn.bob.org.controller;

import cn.bob.basic.utils.AjaxResult;
import cn.bob.basic.utils.PageList;
import cn.bob.org.domain.Dictionarydetail;
import cn.bob.org.mapper.DictionarydetailMapper;
import cn.bob.org.query.DictionarydetailQuery;
import cn.bob.org.service.IDictionarydetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author bob
 * @data 2022/10/13-9:52
 */
@RestController
@RequestMapping("/detail")
public class DictionarydetailController {
    @Autowired
    private IDictionarydetailService service;


    @GetMapping
    public List<Dictionarydetail> findAll(){
        return service.findAll();
    }

    @PostMapping
    public PageList<Dictionarydetail> queryByPage(@RequestBody DictionarydetailQuery query){
        return service.queryByPage(query);
    }

    @PutMapping
    public AjaxResult addorup(@RequestBody Dictionarydetail dictionarydetail){
        if (null==dictionarydetail.getId()){
            System.out.println(dictionarydetail);
            service.add(dictionarydetail);
        }else {
            service.update(dictionarydetail);
        }
        return AjaxResult.me().success();
    }
    @DeleteMapping("/{id}")
    public AjaxResult delById(@PathVariable("id")Long id){
        service.delById(id);
        return AjaxResult.me().success();
    }
    @PatchMapping
    public AjaxResult batchDel(@RequestBody List<Long> ids){
        service.batchDel(ids);
        return AjaxResult.me().success();
    }
}
